#include "KcPickFacePhoto.h"
#include <QImage>
#include "dep/libfacedetection/facedetectcnn.h"

void KcPickFacePhoto::doCalc_(const QString& filePath, void* fileObj)
{
    //!!! The input image must be a BGR one (three-channel) instead of RGB
    auto img = ((QImage*)fileObj)->convertToFormat(QImage::Format_BGR888);
    if (img.width() > 480 || img.height() > 480) // 太大就缩放，提高识别速度
        img = img.scaled(480, 480, Qt::KeepAspectRatio);

    auto r = objectdetect_cnn((unsigned char*)img.constBits(), img.width(), img.height(), img.bytesPerLine(), similarity_);
    tryEmitResult_(filePath, !r.empty());
}
